package org.gardenXml;

import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.logging.Logger;

public class TestUser {
    private static Logger logg = Logger.getLogger("TestUser");
    @Test
    public static void main(String[] args) {
        ApplicationContext context =new ClassPathXmlApplicationContext("bean.xml");
       //id获取
        User user = (User) context.getBean("user");
        logg.info("id获取:"+user);
        user.run();
        //类获取
        User user1 = context.getBean(User.class);
        logg.info("类获取:"+user1);
//根据id和类型
        User user2 = context.getBean("user",User.class);
        logg.info("根据id和类型:"+user2);
    }
}
